<template>
	<view class="page-content">
		<u-list v-if="dataList.length" @scrolltolower="listScrollTolower">
			<view class="itemBox" v-for="(item, index) in dataList" :key="index" @click="itemClick(item)">
				<view class="box">
					<view class="c_000000 f_36" style="font-weight: bold;">{{item.name}}</view>
					<view class="c_999999 f-24 mt-10" style="text-align: right;">{{showTime(item.create_at)}}</view>
				</view>
			</view>
		</u-list>
		<u-empty mode="list" v-else :customStyle="{flex:'1'}"></u-empty>
	</view>
</template>

<script>
	import {
		getNotify
	} from '@/config/api.js'
	export default {
		data() {
			return {
				dataList: [],
				page: 1,
				pages: 1,
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			getList() {
				getNotify({
					page: this.page
				}).then((res) => {
					this.dataList = this.dataList.concat(res.list);
					this.pages = res.page.pages;
					this.page++;
				}).catch((err) => {

				});
			},
			listScrollTolower() {
				if (this.page <= this.pages) {
					this.getList();
				}
			},
			showTime(time) {
				return time.substr(0, 12);
			},
			itemClick(item) {
				uni.$u.route({
					url: "/pages/webview/webview?tag=notify&id=" + item.id,
					type: "navigateTo"
				})
			}
		}
	}
</script>

<style scoped>
	.itemBox {
		width: 100%;
		padding: 0 20rpx;
		margin-top: 20rpx;
		box-sizing: border-box
	}

	.box {
		border-radius: 20rpx;
		background-color: #fff;
		padding: 20rpx;
	}
</style>
